package com.qyer.lxp.service.location.impl;

import com.qyer.lxp.common.framework.core.BaseSpringService;
import com.qyer.lxp.dao.location.LocationMapper;
import com.qyer.lxp.lxdao.location.ILocationDao;
import com.qyer.lxp.model.location.normal.Location;
import com.qyer.lxp.service.location.ILocationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 获取地理位置(国家/城市/区域)信息实现类
 * Created by jiangping on 16/5/13.
 */
@Service
public class LocationServiceImpl extends BaseSpringService implements ILocationService {

    @Resource
    private ILocationDao locationDao;

    @Resource
    private LocationMapper locationMapper;

    /**
     * 获取地理位置(国家/城市/区域)信息
     * 功能说明：获取地理位置(国家/城市/区域)信息,
     * 可以获取每个地理位置在力行系统的编码。
     *
     * @return 返回地理信息
     * @throws Exception
     */
    public List<Location> getLocationInfo() {

        try {
            return locationDao.getLocationInfo();
        } catch (Exception e) {
            logger.error("调取力行地理位置接口失败：",e);
        }
        return null;
    }

    /**
     * 插入区域信息
     * @param model
     * @return
     */
    public int insertLocation(Location model){
        return locationMapper.insertLocation(model);
    }

    /**
     * 根据code获取区域信息
     * @param code
     * @return
     */
    public Location getLocationByCode(String code){
        return locationMapper.getLocationByCode(code);
    }
}
